package com.unimas.dof.converter;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

public class BooleanConverter implements Converter {

	public Object convert(Class type, String paramName, HttpServletRequest request) {
		
		Map<String,String[]> parameters = request.getParameterMap();
		
		String value[] = parameters.get(paramName);
		if(type.equals(boolean.class)){
			if(value == null){
				return 0;
			}else{
				return Boolean.parseBoolean(value[0]);
			}
		}else{
			if(value == null){
				return null;
			}else{
				return Boolean.parseBoolean(value[0]);
			}
		}
	}

}
